using System;
using System.Reflection;
using Moq;
using NUnit.Framework;
using SpecMaker.Core;
using SpecMaker.Core.Dsl;
using SpecMaker.Core.Interfaces;
using SpecMaker.UnitTests.SupportClasses;
using It=Moq.It;

namespace SpecMaker.UnitTests
{
    [TestFixture]
    public class SpecSpecrRunnerWhenLoadingAssembly
    {
        private SpecRunner runner;
        private Mock<IAssemblyTypeLoader> typeloader;
        private Mock<ISpecFinder> finder;
        private Mock<IReportFactory> reporter;
        [SetUp]
        public void SetUp()
        {
            typeloader = new Mock<IAssemblyTypeLoader>();
            finder = new Mock<ISpecFinder>();
            reporter = new Mock<IReportFactory>();

            typeloader.Setup(x => x.Get(It.IsAny<string>())).Returns(new []{typeof(TestBaseContainer)});
            finder.Setup(find => find.GetImpl(It.IsAny<Type[]>())).Returns(new[] {new TestBaseContainer()});
            reporter.Setup(report => report.FromSpecContainers(It.IsAny<SpecResult[]>()));



            runner = new SpecRunner(typeloader.Object, finder.Object, reporter.Object,new RuleExecutor() );

            runner.Execute("loc");
        }

        [Test]
        public void should_load_all_assembly_types()
        {
           
            typeloader.Verify(x=>x.Get(It.IsAny<string>()));
        }

        [Test]
        public void should_search_types_return_for_speccontainers()
        {

             
            finder.Verify(x=>x.GetImpl(It.IsAny<Type[]>()));
        }

        [Test]
        public void should_build_reports_from_spec_containers()
        {
            reporter.Verify(x=>x.FromSpecContainers(It.IsAny<SpecResult[]>()));
            
            
        }
    }
}